<template>
	<view>
		<view class="header">
			<image class="bg" src="../../../static/img/personCenter/headerBg.png" mode=""></image>
			<view class="msg" @click="onNavigateTo('/pages/tabbar/personCenter/news')">
				<image class="msg_img" src="../../../static/img/personCenter/msg.png" mode=""></image>
				<image class="msg_redRound" src="../../../static/img/personCenter/redRound.png" mode=""></image>
			</view>
			<view class="userInfo">
				<!-- <image :src="avatar?avatar:'../../../static/img/index/12.jpg'" mode=""></image> -->
				<u-avatar style="margin-right: 30rpx;" size="large" :src="avatar"></u-avatar>
				<text>{{ nickname ? nickname : '请先登录' }}</text>
			</view>
			<view class="wallet">
				<view class="wallet_left" @click="onNavigateTo('/pages/tabbar/personCenter/myWallet/myWallet')">
					<text>{{ money ? money : '0.00' }}</text>
					<text>余额</text>
				</view>
				<view class="line"></view>
				<view class="wallet_right" @click="onNavigateTo('/pages/tabbar/personCenter/myWallet/discount')">
					<text>{{ coupon ? coupon : '暂无' }}</text>
					<text>优惠券</text>
				</view>
			</view>
		</view>
		<view class="container">
			<view class="select">
				<view class="select_info borderBottom2" @click="onNavigateTo('/pages/tabbar/personCenter/userInfo')">
					<view class="select_info_left">
						<image src="../../../static/img/personCenter/infoIcon.png" mode=""></image>
						<text>个人信息</text>
					</view>
					<view class="select_info_right iconfont"><text class="iconfont">&#xe79a;</text></view>
				</view>
				<view class="select_info borderBottom2" @click="onNavigateTo('/pages/tabbar/personCenter/userOrder')">
					<view class="select_info_left">
						<image src="../../../static/img/personCenter/orderIcon.png" mode=""></image>
						<text>考试车订单</text>
					</view>
					<view class="select_info_right iconfont"><text class="iconfont">&#xe79a;</text></view>
				</view>
				<view class="select_info borderBottom2" @click="onNavigateTo('/pages/tabbar/personCenter/testOrder')">
					<view class="select_info_left">
						<image src="../../../static/img/personCenter/orderIcon.png" mode=""></image>
						<text>教练车订单</text>
					</view>
					<view class="select_info_right iconfont"><text class="iconfont">&#xe79a;</text></view>
				</view>
				<view class="select_info borderBottom2" @click="onNavigateTo('/pages/tabbar/personCenter/myTeacher')">
					<view class="select_info_left">
						<image src="../../../static/img/personCenter/myTeacherIcon.png" mode=""></image>
						<text>我的教练</text>
					</view>
					<view class="select_info_right iconfont"><text class="iconfont">&#xe79a;</text></view>
				</view>
				<view class="select_info borderBottom2" @click="onNavigateTo('/pages/tabbar/personCenter/myWallet/myWallet')">
					<view class="select_info_left">
						<image src="../../../static/img/personCenter/walletIcon.png" mode=""></image>
						<text>我的钱包</text>
					</view>
					<view class="select_info_right iconfont"><text class="iconfont">&#xe79a;</text></view>
				</view>
				<view class="select_info" @click="goTo">
					<view class="select_info_left">
						<image src="../../../static/img/personCenter/integralIcon.png" mode=""></image>
						<text>我的积分</text>
					</view>
					<view class="select_info_right ">
						<text style="font-size: 28rpx;color: #848488;">{{ score ? score + '分' : '' }}</text>
						<text class="iconfont">&#xe79a;</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import url from '@/tool/index.js';
import { index } from '@/api/user/userCenter/userCenter.js';
import { wxSign } from '@/api/wxSign/wxSign.js';
export default {
	data() {
		return {
			nickname: '',
			money: '',
			coupon: '',
			score: '',
			avatar: ''
		};
	},
	async onShow() {
		let res = await index();
		this.avatar = res.data.user.avatar;
		this.nickname = res.data.user.nickname;
		this.money = res.data.user.money;
		this.coupon = res.data.couponcount;
		this.score = res.data.user.score;
	},
	onLoad() {
		this.shareAll();
	},
	methods: {
		onNavigateTo(url) {
			uni.navigateTo({
				url: url
			});
		},
		goTo() {
			window.location.href = 'http://qianhe.westts.cn/addons/leescore';
		},
		async shareAll() {
			let res = await wxSign();
			let local = 'http://qianhe.westts.cn/index.html';
			let shareContent = res.data.share;
			if ((res.code = 1)) {
				wx.config({
					debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
					appId: res.data.wxaccessdata.appId, // 必填，公众号的唯一标识
					timestamp: res.data.wxaccessdata.timestamp, // 必填，生成签名的时间戳
					nonceStr: res.data.wxaccessdata.nonceStr, // 必填，生成签名的随机串
					signature: res.data.wxaccessdata.signature, // 必填，签名，见附录1
					jsApiList: [
						'onMenuShareAppMessage', //微信分享
						'onMenuShareTimeline', //微信分享
						'chooseWXPay', //微信支付
						'showOptionMenu',
						'updateAppMessageShareData',
						'hideMenuItems',
						'showMenuItems'
					]
				});
				wx.ready(function() {
					wx.onMenuShareAppMessage({
						title: shareContent.sharetitle, // 分享标题
						desc: shareContent.sharedesc,
						link: 'http://qianhe.westts.cn/index.html?id=' + res.data.share.shareid + '#/', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
						imgUrl: 'http://qianhe.westts.cn' + shareContent.shareimg, // 分享图标
						success: function() {}
					});
					wx.onMenuShareTimeline({
						title: shareContent.sharetitle, // 分享标题
						link: 'http://qianhe.westts.cn/index.html?id=' + res.data.share.shareid + '#/', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
						imgUrl: 'http://qianhe.westts.cn' + shareContent.shareimg, // 分享图标
						success: function() {
							// 用户点击了分享后执行的回调函数
						}
					});
				});
			}
		}
	}
};
</script>

<style lang="scss">
@import './css/personCenter.scss';
</style>
